<template>
    <Modal
            v-model="modelShow"
            title="人员档案交接"
            @on-ok="okAction"
            @on-cancel="cancelAction">
        <Select v-model="selectCompany" style="width:200px">
            <Option v-for="item in cityList" :value="item.code" :key="item.code">{{ item.name }}</Option>
        </Select>
    </Modal>
</template>

<script>
import { recordConnection, getOfficeList } from '@/api/record'
export default {
  name: 'TurnPeopleModel',
  data () {
    return {
      modelShow: false,
      selectCompany: '',
      cityList: []
    }
  },
  props: {
    options: {
      type: Array,
      default: () => {
        return {}
      }
    }
  },
  methods: {
    modelAction () {
      this.modelShow = !this.modelShow
      this.getOfficeList()
    },
    getOfficeList () {
      let data = {
        parent_id: '044f4fc3-4a38-11ea-ba01-ec0d9acf02d2'
      }
      getOfficeList(data).then(ret => {
        if (ret.data.errcode === 0) {
          this.cityList = ret.data.data
        } else {
          this.$Message.error(ret.data.errmsg)
        }
      })
    },
    okAction () {
      let data = {
        accept_company_code: this.selectCompany,
        selectlist: this.options
      }
      recordConnection(data).then(ret => {
        if (ret.data.errcode === 0) {
          this.selectCompany = ''
          this.$emit('clean')
          this.$Message.success(ret.data.errmsg)
        } else {
          this.$Message.error(ret.data.errmsg)
        }
      })
    },
    cancelAction () {
      this.modelShow = false
    }
  },
  computed: {
    getUploadUrl () {
      return this.$config.upLoadFileUrl
    }
  }
}
</script>

<style scoped>

</style>
